package com.example.shopping.dto;

/**
 * 功能：
 * 作者：张赛特
 * 日期：2025/11/17 17:32
 */


import lombok.Getter;
import lombok.Setter;

/**
 * 统一返回值
 */
@Setter
@Getter
public class Result {
    /**
     * 响应状态码
     */
    private int code=200;
    /**
     * 响应提示消息
     */
    private String msg="成功";
    /**
     * 响应结果
     */
    private Object data;

    public static Result ok(){
        return new Result();
    }
    public static Result ok(Object data){
        return new Result(data);
    }
    public static Result error(String msg){
        return new Result(msg);
    }
    public Result() {
    }
    public Result(Object data) {
        this.data = data;
    }
    public Result(String msg) {
        this.code = -1;
        this.msg = msg;
    }
    public Result(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
}
